<%--
  Created by IntelliJ IDEA.
  User: 王德明
  Date: 2018/4/28
  Time: 14:23
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<div class="modal-header">
    <button class="close" ng-click="cancel()">
        <span aria-hidden="true">×</span>
    </button>
    <h3 class="modal-title" id="modal-title">风控外置管理</h3>
</div>

<div class="modal-body" id="modal-body">
    <div class="ibox-content no-borders tab-content">
        <!--添加-->
        <form name="myForm" class="form-horizontal formTopSpacing" ng-model="addriskouter" ng-show="type == 0">
            <!-- 类型-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span class="text-danger">*</span>类型：</label>
                <div class="col-sm-8">
                    <select id="type" name="type" class="form-control" ng-model="addriskouter.refType" ng-blur="typeBlur($event,addriskouter.refType)" required>
                        <option value="" ></option>
                        <option value="0">通用</option>
                        <option value="1">收单机构</option>
                        <option value="2">商户</option>
                        <option value="3">域名</option>
                    </select>
                </div>
            </div>
            <!-- 名称-->
            <div class="form-group" ng-show="addriskouter.refType != '0' && addriskouter.refType != '1' && addriskouter.refType != '2' && addriskouter.refType != '3'">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="addriskouter.refId"
                            ng-blur="nameBlur($event,addriskouter.refId)" required>
                        <option  ng-value=""></option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="addriskouter.refType == '0'">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="addriskouter.refId" ng-blur="nameBlur($event,addriskouter.refId)" required>
                        <option ng-value="0">通用</option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="addriskouter.refType == '1'">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select  name="name" class="form-control" ng-model="addriskouter.refId"
                             ng-blur="nameBlur($event,addriskouter.refId)" required>
                        <option  ng-repeat="x in init.acquirer" ng-value="x.id">
                            {{ x.name }}
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="addriskouter.refType == '2'">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="addriskouter.refId"
                            ng-blur="nameBlur($event,addriskouter.refId)" required>
                        <option  ng-repeat="x in init.merchant" ng-value="x.id">
                            ({{ x.id }}) {{ x.name }}
                        </option>
                    </select>
                </div>
            </div>
            <div class="form-group" ng-show="addriskouter.refType == '3'">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span
                        class="text-danger">*</span>名称：</label>
                <div class="col-sm-8">
                    <select name="name" class="form-control" ng-model="addriskouter.refId"
                            ng-blur="nameBlur($event,addriskouter.refId)" required>
                        <option ng-repeat="x in init.siteurl" ng-value="x.id">
                            {{ x.siteUrl }}
                        </option>
                    </select>
                </div>
            </div>
            <!-- 风控类型-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span class="text-danger">*</span>风控类型:</label>
                <div class="col-sm-8">
                    <select id="risktype" name="risktype" class="form-control" ng-model="addriskouter.element" ng-blur="risktypeBlur($event,addriskouter.element)" required>
                        <option value=""></option>
                        <option ng-repeat="x in init.extrisk" value="{{ x.id }}">
                            {{ x.name }}
                        </option>
                    </select>
                </div>
            </div>
            <!--元素键值-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span class="text-danger">*</span>元素键值:</label>
                <div class="col-sm-8">
                    <input id="elementkey" name="elementkey" class="form-control" ng-model="addriskouter.elementValue" ng-keyup="elementkeyBlur($event,addriskouter.elementValue)" required>
                </div>
            </div>
            <!--状态-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span class="text-danger">*</span>状态:</label>
                <div class="col-sm-8">
                    <select name="status" class="form-control" ng-model="addriskouter.status" ng-blur="statusBlur($event,addriskouter.status)" required>
                        <option value=""></option>
                        <option value="1">启用</option>
                        <option value="0">禁用</option>
                    </select>
                </div>
            </div>
            <!--备注-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle">备注:</label>
                <div class="col-sm-8">
                    <input class="form-control" ng-model="addriskouter.remark">
                </div>
            </div>
        </form>
        <!--更新-->
        <form name="myFormupdate" class="form-horizontal formTopSpacing" ng-model="risk" ng-show="type == 1">
            <!-- 类型-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span class="text-danger">*</span>类型：</label>
                <div class="col-sm-8">
                    <select  name="typeupdate" class="form-control" ng-model="risk.refType" ng-blur="typeupdateFocus($event,risk.refType)" required>
                        <option value="" ></option>
                        <option value="0">通用</option>
                        <option value="1">收单机构</option>
                        <option value="2">商户</option>
                        <option value="3">域名</option>
                    </select>
                </div>
            </div>
            <!-- 名称-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span class="text-danger">*</span>名称:</label>
                <div class="col-sm-8">
                    <select  name="nameupdate" class="form-control" ng-model="risk.refId" ng-blur="nameupdateFocus($event,risk.refId)" required>
                        <option ng-repeat="x in initParam" value="{{ x.id }}">
                            {{ x.name !=undefined ? x.name : x.siteUrl }}
                        </option>
                    </select>
                </div>
            </div>
            <!-- 风控类型-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span class="text-danger">*</span>风控类型:</label>
                <div class="col-sm-8">
                    <select  name="risktypeupdate" class="form-control" ng-model="risk.element" ng-blur="risktypeupdateFocus($event,risk.element)" required>
                        <option ng-repeat="x in init.extrisk" value="{{ x.id }}">
                            {{ x.name }}
                        </option>
                    </select>
                </div>
            </div>
            <!--元素键值-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span class="text-danger">*</span>元素键值:</label>
                <div class="col-sm-8">
                    <input  name="elementkeyupdate" class="form-control" ng-model="risk.elementValue" ng-keyup="elementkeyupdateFocus($event,risk.elementValue)" required>
                </div>
            </div>
            <!--状态-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle"><span class="text-danger">*</span>状态:</label>
                <div class="col-sm-8">
                    <select name="status" class="form-control" ng-model="risk.status" ng-blur="statusupdateBlur($event,risk.status)" required>
                        <option value=""></option>
                        <option value="1">启用</option>
                        <option value="0">禁用</option>
                    </select>
                </div>
            </div>
            <!--备注-->
            <div class="form-group">
                <label class="col-sm-3 control-label formTextVerticalMiddle">备注:</label>
                <div class="col-sm-8">
                    <input class="form-control" ng-model="risk.remark">
                </div>
            </div>
        </form>
    </div>
</div>

<div class="modal-footer">
    <row>
        <div class="col-sm-12">
            <div class="center">
                <button class="btn btn-sm btn-primary general-btn" type="button"
                        ng-click="insertRiskOuter(addriskouter,0)"
                        ng-disabled="!myForm.type.$valid || !myForm.name.$valid || !myForm.risktype.$valid || !myForm.elementkey.$valid || !myForm.status.$valid"
                        ng-show="type == 0">
                    确定
                </button>
                <button class="btn btn-sm btn-primary general-btn" type="button" ng-click="updateRiskOuter(risk,1)"
                        ng-disabled="nextDisabled(myFormupdate)"
                        ng-show="type == 1">
                    确定
                </button>
            </div>
        </div>
    </row>
</div>